import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

// layout
import { LayoutBasicComponent } from './layout/basic/basic.component';

// core
import { LoginComponent } from '@/core/base/passport/login/login.component';
import { Exception404Component } from '@/core/base/exception/404.component';
import { AuthGuard } from '@/core/auth/auth.guard';

import { DashboardComponent } from '@/pages/dashboard/dashboard.component';
import { UserManagementComponent } from '@/pages/user-management/user-management.component';

import { ArticleManagementComponent } from '@/pages/article-management/article-management.component';
import { ArticleDetailComponent } from '@/pages/article-management/article-detail/article-detail.component';

const routes: Routes = [
  {
    path: '',
    component: LayoutBasicComponent,
    canActivate: [AuthGuard],
    children: [
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
      { path: 'dashboard', component: DashboardComponent },
      { path: 'UserManagement', component: UserManagementComponent },
      { path: 'ArticleManagement', component: ArticleManagementComponent },
      { path: 'articles/:id', component: ArticleDetailComponent },
    ],
  },
  {
    path: 'login',
    component: LoginComponent,
  },
  { path: '**', component: Exception404Component },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule {}
